import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:line_icons/line_icons.dart';

class SearchTile extends StatelessWidget {
  final VoidCallback? bookshelfTap; //书架点击事件
  const SearchTile({super.key, this.bookshelfTap});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        //搜索框
        _buildSearch(context),
        // 书架图标
        _buildSearchIcon(),
      ],
    );
  }

  Widget _buildSearch(BuildContext context) {
    return Expanded(
      child: Container(
        alignment: Alignment.centerLeft,
        padding: EdgeInsets.only(
          left: 15.w,
        ),
        height: 20.h,
        decoration: BoxDecoration(
          color: Theme.of(context).colorScheme.secondary,
          borderRadius: BorderRadius.circular(12.r), //圆角
        ),
        child: Text(
          "搜索",
          style: TextStyle(
              fontSize: 24.sp,
              color: Theme.of(context).colorScheme.inversePrimary),
        ),
      ),
    );
  }

  Widget _buildSearchIcon() {
    return Container(
      padding: EdgeInsets.only(left: 10.w),
      child: IconButton(
        padding: EdgeInsets.zero,
        onPressed: bookshelfTap,
        icon: Icon(LineIcons.stream, size: 40.r), //图标
      ),
    );
  }
}
